home *** CD-ROM | disk | FTP | other *** search
/ Loadstar 49 / 049.d81 / base converter (.txt) < prev    next >
Commodore BASIC  |  2022-08-26  |  741b  |  21 lines

  1. 10 poke53280,.:poke53281,.
  2. 100 print"[147] [154]universal base converter - art skiles":er$="^^?"
  3. 110 n$="":input "numeral to convert";n$:if n$="" then end
  4. 120 input"  from base (2-36)";f:if f<2 or f>36 then print tab(20);er$:goto 120
  5. 130 input"    to base (2-36)";t:if t<2 or t>36 then print tab(20);er$:goto 130
  6. 140 x=0:for z=1 to len(n$):a=asc(mid$(n$,z,1))
  7. 150 b=a+48*(a>47 and a<58)+55*(a>64 and a<91)+85*(a>96 and a<123)
  8. 160 if b>=f then print "error in numeral to convert!":goto 110
  9. 170 x=x*f+b:next z:cn$=""
  10. 180 b=x-int(x/t)*t:x=(x-b)/t
  11. 190 a=b-48*(b<10)-55*(b>9)
  12. 200 cn$=chr$(a)+cn$:if x then 180
  13. 210 print " converted numeral: ";cn$
  14. 220 print"press space to convert another or"
  15. 230 print"q to quit."
  16. 240 a=peek(203):ifa<>60anda<>62then240
  17. 250 ifa=60thenrun
  18. 260 print"[147][144]load"chr$(34)"tips and tricks"chr$(34)",8"
  19. 270 print"run"
  20. 280 poke631,13:poke632,13:poke198,2:end
  21.